<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:h="http://java.sun.com/jsf/html">
	
	<ui:remove>
		<!-- COMMENT
			Description: Only use this tag when dirty checking is required.
			Parameters:
				+ hFormId:
				+ hFormRendered:
				+ hFormStyleClass
				+ hFormCheckDirty: true/false default is true
		 -->
	</ui:remove>
	
	<ui:remove><!-- COMMENT: set default value --></ui:remove>
	<c:if test="#{empty rendered or rendered == ''}">
		<c:set var="rendered" value="true" />
	</c:if>
	<c:if test="#{empty hFormCheckDirty or hFormCheckDirty == ''}">
		<c:set var="hFormCheckDirty" value="true" />
	</c:if>
	
	<c:set var="styleClassWithDirtyCheck" value="#{hFormCheckDirty == 'true' ? 'tacho_dirty_check' : ''}  #{hFormStyleClass}" />

	<ui:remove><!-- COMMENT: body of this component --></ui:remove>
	<h:form id="#{hFormId}" 
		rendered="#{rendered}" 
		styleClass="#{styleClassWithDirtyCheck}">
		<c:if test="#{hFormCheckDirty == 'true'}">
			<script type="text/javascript">
				Tacho.DirtyChecker.observeFormDirty('#{rich:clientId(hFormId)}');
			</script>
			<c:if test="#{validation.failed}">
				<script type="text/javascript">
					Tacho.DirtyChecker.setFormDirty('#{rich:clientId(hFormId)}', true);
				</script>
			</c:if>
		</c:if>

		<ui:insert/>
		
		<script type="text/javascript">
			Tacho.Form.onFormRender('#{rich:clientId(hFormId)}');
		</script>
		
	</h:form>
	
</ui:composition>
